Skip to content

fix(workflows): deduplicate generated workflow names - #6935

Merged
j15z merged 2 commits into
stagingfrom
fix/generated-workflow-name-deduplication
Aug 21, 2026
Merged

fix(workflows): deduplicate generated workflow names#6935
j15z merged 2 commits into
stagingfrom
fix/generated-workflow-name-deduplication

Conversation

@j15z

@j15z j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

Generated workflows now request server-side name deduplication in both root and folder creation paths, so concurrent or repeated creation does not surface avoidable name conflicts. Deduplicated creates retry workflow-name unique-index races with a freshly computed name, while exact-name conflicts and unrelated database violations keep their existing behavior. Folder creation also depends on the stable mutation function, which keeps its callback stable when mutation state changes.

This is the foundation of a two-PR stack. #6906 adds the new generated-name vocabulary on top.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • bun run --cwd apps/sim test -- lib/workflows/utils.test.ts lib/workflows/orchestration/workflow-lifecycle.test.ts 'app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workflow-operations.test.tsx' (25 tests passed)
  • bun run --cwd apps/sim test -- lib/workflows/orchestration/workflow-lifecycle.test.ts (5 tests passed after the race-retry fix)
  • bun run check:api-validation
  • bun run lint (passes with one pre-existing unused-suppression warning)
  • bun run check

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

Not applicable; this changes workflow creation behavior without changing the interface.

@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 21, 2026 5:58pm

Request Review

@cursor

cursor Bot commented Aug 21, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Touches workflow creation and unique-name handling under concurrency, so a retry/loop bug could fail creates or hide real unique-constraint errors. Exact-name creates still return conflicts.

Overview
Generated workflow creates from the sidebar (root and folder) now pass deduplicate: true, so the server picks a unique name instead of failing on collisions.

performCreateWorkflowTransition re-runs deduplicateWorkflowName inside a retry loop (up to 8 attempts) when the unique name index is hit by a race. Exact-name creates still return a conflict. Folder create also depends on the stable mutate function so the callback does not churn with mutation state.

Tests cover the client flag, suffix selection, and the concurrent-claim retry path.

Reviewed by Cursor Bugbot for commit 9ab4733. Bugbot is set up for automated code reviews on this repo. Configure here.

@j15z j15z changed the title fix/generated workflow name deduplication fix(workflows): deduplicate generated workflow names Aug 21, 2026
@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR enables server-side deduplication for generated workflow names created from both root and folder sidebar actions and adds focused tests for the new request and lifecycle behavior.

  • Passes deduplicate: true from both generated-workflow creation paths.
  • Verifies lifecycle name replacement and suffix selection.
  • Stabilizes the folder-item callback dependency by extracting the mutation function.

Confidence Score: 4/5

The PR should not merge until deduplicated creation handles concurrent name collisions instead of silently dropping one creation after navigation.

Both changed UI paths expose a non-atomic read-before-insert deduplication flow whose unique-conflict handler returns an error without retrying, leaving the optimistic caller on a workflow ID that was never created.

Files Needing Attention: apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workflow-operations.ts, apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/folder-item/folder-item.tsx

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workflow-operations.ts Enables deduplication for root workflow creation, but concurrent requests can still conflict after navigating optimistically.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workflow-list/components/folder-item/folder-item.tsx Enables the same deduplication behavior for folder-scoped creation and shares the unresolved concurrent-create failure.
apps/sim/lib/workflows/orchestration/workflow-lifecycle.test.ts Covers successful deduplication but does not exercise the unique-constraint race or retry behavior.
apps/sim/lib/workflows/utils.test.ts Adds focused coverage for choosing the next available numerical suffix.
apps/sim/app/workspace/[workspaceId]/w/components/sidebar/hooks/use-workflow-operations.test.tsx Verifies that generated root workflow creation requests server-side deduplication.

Reviews (1): Last reviewed commit: "fix(workflows): deduplicate generated wo..." | Re-trigger Greptile

- recompute generated names after workflow-name conflicts
- preserve exact-name and unrelated constraint behavior
- cover the concurrent-create retry path
@j15z

j15z commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

Two overlapping generated-name creates can select the same suffix; one loses the unique-index race and fails after optimistic navigation.

Addressed in 9ab4733: deduplicated creates now retry the workflow-name unique-index race with a freshly computed name, bounded to eight attempts. Exact-name creates retain conflict behavior, and unrelated 23505 violations still propagate.

@j15z
j15z merged commit 2252ac0 into staging Aug 21, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant